package com.ant.user.utils;

import java.util.Random;

public class GenerateString {
    public static String generateCode() {
        Random random = new Random();
        StringBuilder code = new StringBuilder();
        for (int i = 0; i < 6; i++) {
            // 生成 0 - 9 的随机数字
            int digit = random.nextInt(10);
            code.append(digit);
        }
        return code.toString();
    }

    public static String generatePassphrase(int length){
        String AllLetter = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890+-_*!?";
        StringBuffer result = new StringBuffer();
        Random random = new Random();
        for(int i=0; i<length; i++) {
            result.append(AllLetter.charAt(random.nextInt(AllLetter.length())));
        }
        return result.toString();
    }

    public static String generateAccount(int length){
        String AllLetter = "abcdefghijklmnopqrstuvwxyz1234567890";
        StringBuffer result = new StringBuffer();
        Random random = new Random();
        for(int i=0; i<length; i++) {
            result.append(AllLetter.charAt(random.nextInt(AllLetter.length())));
        }
        return result.toString();
    }
}
